|
|
|
|
|
|
|
Unicode internally for string storage, so in most cases you can assume that a BSTR contains a Unicode string. One major exception will be discussed later in this chapter. |
|
|
|
|
|
|
|
|
Figure T5-5:
BSTR and NULL-terminated strings |
|
|
|
|
|
|
|
|
The second thing you may notice is that a BSTR includes the length of the string. The length appears in the four bytes preceding the string data. When you have a pointer to a BSTR, the pointer always refers to the start of the data area. |
|
|
|
|
|
|
|
|
The ByValSt.vbp example program demonstrates this with the following code: |
|
|
|
|
|
|
|
|
Private Sub cmdInside_Click()
Dim a() As Byte
Dim x&
Dim b$
Dim length As Long
b$ = "Hello"
' Many VB programmers are not aware that you can
' do dynamic assignment like this
a() = b$
Debug.Print "Inside Hello"
For x = 0 To UBound(a)
Debug.Print x, Hex$(a(x))
Next x |
|
|
|
|
|